// W25Q64 存储演示代码
// 使用了lowpowerlab/SPIFlash

#include <cupeW25q64.h>

void CupeW25Q64::init()
{
  flash = new SPIFlash(FLASH_CS);

  if (flash->initialize())
  {
    dbLog("W25Q64 init success.\n");
    dbLog("W25Q64 chip id: %016X\n", flash->readUniqueId());

    flash->blockErase4K(0);

    char iwin[] = "Hello, i m iwinyeah";
    flash->writeBytes(0, (byte *)iwin, 20);

    char str[32];
    flash->readBytes(0, (byte *)str, 32);
    dbLog("W25Q64 str: %s\n", str);
  }
  else
  {
    dbLog("W25Q64 init failed.\n");
  }
}
